//
//  WBNavgationController.swift
//  XLWebo
//
//  Created by 陈晓龙 on 17/2/15.
//  Copyright © 2017年 陈晓龙. All rights reserved.
//

import UIKit

class WBNavgationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    
     navigationBar.isHidden = true
    }

   //重写父类方法 隐藏底部tabbar
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        //如果不是栈底的控制器才需要隐藏，跟控制器不需要处理
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            
            if let vc = viewController as? BaseViewController {
                var title = "返回"
                //只有一个控制器的时候显示栈底的标题
                if childViewControllers.count == 1 {
                    title = childViewControllers.first?.title ?? "返回"
                }
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, fontSize: 16, target: self, action: #selector(goBack) ,isBack:true)
            }
        }
       
         super.pushViewController(viewController, animated: animated)
    }
    
    
    @objc private func goBack() {
       popViewController(animated: true)
    }
    
    //MARK -- END

}
